﻿
#include "pch.h"
#include <iostream>
using namespace std;
#define dim 3
 
template <class T> 
//#define T int
#define T double

class cbox
{
public:
	T m_pmin[dim], m_pmax[dim];

public:
	cbox()
	{
		m_pmin[0] = 0;
		m_pmax[0] = -1;
	}

	bool isnull()
	{
		return m_pmin[0] > m_pmax[0];
	}
	void addpoint(T pt[dim])
	{
		int i;
		if (isnull())
		{
			for (i = 0; i < dim; i++)
			{
				m_pmin[i] = m_pmax[i] = pt[i];
			}
			return;
		}
		for (i = 0; i < dim; i++)
		{
			if (pt[i] < m_pmin[i])
				m_pmin[i] = pt[i];
			else if (pt[i] > m_pmax[i])
				m_pmax[i] = pt[i];
		}
	}
	void addbox(cbox bx)
	{
		addpoint(bx.m_pmin);
		addpoint(bx.m_pmax);
	}
	int inside(T pt[dim])
	{
		int i;
		for (i = 0; i < dim; i++)
		{
			if (pt[i]<m_pmin[i] || pt[i] > m_pmax[i])
				return 0;
		}
		return 1;
	}

	void output()
	{
		int i;
		cout << "<";
		for (i = 0; i < dim; i++)
		{
			cout << " " << m_pmin[i] << " ";
		}
		cout << ">";

		cout << "<";
		for (i = 0; i < dim; i++)
		{
			cout << " " << m_pmax[i] << " ";
		}
		cout << ">";
	}
};


int main()
{
	cbox<int> bx;
	//维度2维
	//int pt[2] = {1,2};
	//bx.addpoint(pt);
	//维度1维
	//int pt[6][1] = { 2,3,5,2,7,6 };
	//维度3 维
	double pt[3][3] = { {2.1,3.5,5.6},{2.1,7,6.5},{4.4,6.6,3} };
	
	
	for (int i = 0; i < 3; i++)
	{
		bx.addpoint(pt[i]);
	}
	bx.output();
}

